package com.huawei.appmarket.framework.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.annotation.Nullable;
import o.Logger;

public class SubHeaderLayout extends RelativeLayout {
    private static final String ˏ = SubHeaderLayout.class.getSimpleName();

    public SubHeaderLayout(Context context) {
        this(context, null);
    }

    public SubHeaderLayout(Context context, @Nullable AttributeSet attributeSet) {
        this(context, attributeSet, 0);
    }

    public SubHeaderLayout(Context context, @Nullable AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
    }

    protected void onLayout(boolean z, int i, int i2, int i3, int i4) {
        View view;
        TextView textView;
        View view2;
        ClassCastException classCastException;
        View view3 = null;
        super.onLayout(z, i, i2, i3, i4);
        int identifier = getContext().getResources().getIdentifier("ItemTitle", "id", getContext().getPackageName());
        try {
            view = (TextView) findViewById(identifier);
            try {
                textView = (TextView) findViewById(getContext().getResources().getIdentifier("more_btn", "id", getContext().getPackageName()));
            } catch (ClassCastException e) {
                view2 = view;
                classCastException = e;
                View view4 = view3;
                Logger.e(ˏ, "error:" + classCastException.getMessage());
                view = view2;
                if (r0 != null) {
                    return;
                }
                return;
            }
            try {
                view3 = findViewById(getContext().getResources().getIdentifier("more_layout", "id", getContext().getPackageName()));
            } catch (ClassCastException e2) {
                ClassCastException classCastException2 = e2;
                view2 = view;
                classCastException = classCastException2;
                Logger.e(ˏ, "error:" + classCastException.getMessage());
                view = view2;
                if (r0 != null) {
                    return;
                }
                return;
            }
        } catch (ClassCastException e3) {
            classCastException = e3;
            textView = view3;
            view2 = view3;
            Logger.e(ˏ, "error:" + classCastException.getMessage());
            view = view2;
            if (r0 != null) {
                return;
            }
            return;
        }
        if (r0 != null && textView != null && view3 != null) {
            int lineCount = r0.getLineCount();
            int top = r0.getTop();
            identifier = r0.getBottom();
            int left = view3.getLeft();
            int right = view3.getRight();
            int measuredHeight = view3.getMeasuredHeight();
            int measuredHeight2 = (measuredHeight - textView.getMeasuredHeight()) / 2;
            if (lineCount > 1) {
                identifier = top - measuredHeight2;
                view3.layout(left, identifier, right, identifier + measuredHeight);
                return;
            }
            identifier += measuredHeight2;
            view3.layout(left, identifier - measuredHeight, right, identifier);
        }
    }
}
